<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>设备检修记录</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
</head>
<body>
  <div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="margin: 20px;"> 
      <div class="record-formtitle">基本信息</div>
      <div class="layui-row basicInfo form-row">
        <div class="layui-col-md6">
          <div class="layui-form-item">
            <div class="layui-inline">
              <label class="layui-form-label">站台名称:</label>
              <div class="layui-input-block">
                <select name="stationName" lay-verify="required" lay-filter="stationNameFilter" id="stationName">
                  <option value="">请选择</option>
                </select>
              </div>
            </div>
          </div>
          <div class="layui-form-item">
            <div class="layui-inline">
              <label class="layui-form-label">系统名:</label>
              <div class="layui-input-block">
                  <select name="system" id="systemList" lay-filter='systemListFilter'>
                      <option value="">请选择</option>
                  </select>
              </div>
            </div>
          </div>
          <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">设备名称：</label>
                <div class="layui-input-block">
                    <select name="productName" lay-verify="required" id="productName">
                      <option value="">请选择</option>
                    </select>
                </div>
            </div>
          </div>
        </div>
      <div class="layui-col-md6">
        <div class="layui-form-item">
          <div class="layui-inline">
            <label class="layui-form-label">专业:</label>
            <div class="layui-input-block">
                <select name="major" id="majorList" lay-filter="majorListFilter">
                    <option value="">请选择</option>
                </select>
            </div>
          </div>
        </div>
        <div class="layui-form-item">
          <div class="layui-inline">
              <label class="layui-form-label">类型：</label>
              <div class="layui-input-block">
                  <select name="equipment" id="equipmentList" lay-filter="equipmentList">
                      <option value="">请选择</option>
                  </select>
              </div>
          </div>
        </div>
      </div>
    </div>
    <div class="record-formtitle">添加检修</div>
      <div class="layui-row form-row">
        <div class="layui-col-md6">
          <div class="layui-form-item">
            <label class="layui-form-label">检修日期:</label>
              <div class="layui-inline">
                  <input type="text" name="maintenanceDate" class="layui-input" id="recordData" placeholder="选择日期时间"  style="padding-right: 30px" lay-verify="required">
              </div>
          </div>
          <div class="layui-form-item">
              <div class="layui-inline">
                  <label class="layui-form-label">检修人:</label>
                  <div class="layui-input-block">
                      <input type="text" name="maintenancePersonName" class="layui-input" style="padding-right: 30px" lay-verify="required">
                  </div>
              </div>
            </div>
        </div>
        <div class="layui-col-md6">
            <div class="layui-form-item">
              <div class="layui-inline">
                  <label class="layui-form-label">检修方式:</label>
                  <div class="layui-input-block">
                      <label class="layui-form-label" style="text-align: left" id="maintenanceWay">检修</label>
                  </div>
              </div>
            </div>
            <div class="layui-form-item">
              <div class="layui-inline">
                  <label class="layui-form-label">工单状态：</label>
                  <div class="layui-input-block">
                      <select name="taskStatus" lay-verify="required">
                          <option value="">请选择</option>
                          <option value="0">未处理</option>
                          <option value="1">处理中</option>
                          <option value="2">搁置</option>
                          <option value="3">已处理</option>
                      </select>
                  </div>
              </div>
            </div>
          </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">检修内容：</label>
        <div class="layui-input-block">
            <input type="text" name="maintenanceContent" class="layui-input" lay-verify="required">
        </div>
      </div>
      <div class="layui-form-item">
        <label class="layui-form-label">具体描述</label>
        <div class="layui-input-block">
          <textarea type="text" name="remark" lay-verify="required" autocomplete="off" class="layui-textarea"></textarea>
        </div>
      </div>
      <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="layuiadmin-app-form-submit" id="layuiadmin-app-form-submit" value="确认添加">
        <input type="button" lay-submit lay-filter="layuiadmin-app-form-edit" id="layuiadmin-app-form-edit" value="确认编辑">
      </div>
    </div>
  <script src="../../layuiadmin/layui/layui.js"></script>  
  <script>
     layui.config({
        base: '../../layuiadmin/' //静态资源所在路径
      }).extend({
        index: 'lib/index' //主入口模块
        , my_send: '../myModules/my_send'
      }).use(['index', 'form','laydate','my_send'], function(){
          var $ = layui.$
          ,form = layui.form
          ,laydate = layui.laydate
          ,my_send = layui.my_send
          ,http_proxy = layui.http_proxy;
          laydate.render({
            elem: '#recordData' //指定元素
          });
          $.ajax({
            url:http_proxy('/dev/station/list'),
            async: false,
            dataType:'json',
            type:'get',
            success:function(data){
              $.each(data.data,function(indexx,itemm){
                $('#stationName').append(new Option(itemm.stationName,indexx));
              })
              form.render('select');
            }
          });
          $.ajax({
            url:http_proxy('/dev/list'),
            async: false,
            dataType:'json',
            type:'get',
            success:function(data){
              $.each(data.data,function(indexxx,itemmm){
                $('#productName').append(new Option(itemmm.productName,indexxx));
              })
              form.render('select');
            }
          });
          form.on('select(stationNameFilter)', function(data){
            $.ajax({
              url:http_proxy('/dev/maintenance/treeData'),
              async: false,
              dataType:'json',
              type:'get',
              success:function(data){
                  $.each(data.data,function(index,item){
                      itemKey = item.key;
                      if(item.level == 0){
                          $('#majorList').append(new Option(item.value,item.key));
                      }
                  })
                  form.render('select');
              }
            });
          });
          form.on('select(majorListFilter)', function(data){
            var dataKey = data.value;
            $.ajax({
              url:http_proxy('/dev/maintenance/treeData'),
              async: false,
              dataType:'json',
              type:'get',
              success:function(data){
                $("#systemList").empty();
                $("#systemList").append(new Option("请选择",""));
                $.each(data.data,function(index1,item1){
                  if(item1.level == 1 && dataKey == item1.pid){
                      $('#systemList').append(new Option(item1.value,item1.key));
                  }
                });
                form.render('select');
              }
            });
         });
        form.on('select(systemListFilter)', function(data){
            var dataKey = data.value;
            $.ajax({
                url:http_proxy('/dev/maintenance/treeData'),
                async: false,
                dataType:'json',
                type:'get',
                success:function(data){
                    $("#equipmentList").empty();
                    $("#equipmentList").append(new Option("请选择",""));
                    $.each(data.data,function(index2,item2){
                        if(item2.level == 2 && dataKey == item2.pid){
                            $('#equipmentList').append(new Option(item2.value,item2.key));
                        }
                    });
                    form.render('select');
                }
            });
        });
        form.on('submit(layuiadmin-app-form-submit)', function(data){
          debugger
      
          var field = data.field,
          index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引  
          $.ajax({
            url: http_proxy("/dev/check/repair/addOrUpdate"),
            type:'POST',
            dataType:'json',
            data:field,
            success:function(data){
              debugger
              if(data.code = 'success'){
                debugger
                layer.msg(data.msg, {icon: 6});
              }else{
                layer.msg(data.msg, {icon: 5});
              }
            }
          });

          parent.layer.close(index); //再执行关闭 

        })
      })
  </script>
</body>
</html>